package com.rgp.servicemap.listener;

import com.rgp.internalcommon.dto.DicDistrict;
import com.rgp.servicemap.event.BatchInsertionEvent;
import com.rgp.servicemap.mapper.DicDistrictMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import java.util.List;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-15 19:34
 */
@Component
public class BatchInsertionListener implements ApplicationListener<BatchInsertionEvent> {

    @Autowired
    private DicDistrictMapper dicDistrictMapper;

    @Override
    public void onApplicationEvent(BatchInsertionEvent event) {
        List<DicDistrict> list = event.getDicDistrictList();
//        dicDistrictMapper.insertBatchSomeColum(list);
        dicDistrictMapper.insertBatch(list);
        System.out.println("数量：" + list.size());
    }
}